<script>
// function delay(ms, callback) {
//   setTimeout(callback, ms);
// }
// // 回调地狱
// delay(2000, ()=>{
//   delay(2000, ()=>{
//     console.log(2)
//     delay(1000, () => console.log(3))
//   })
//   console.log(1)
// })

function delay(ms) {
  return new Promise((resolve, reject) => {
    setTimeout(resolve, ms)
  })
}
delay(2000).then(() => {
  console.log(1)
  return delay(2000)
})
.then(() => {
  console.log(2)
  return delay(1000)
})
.then(() => console.log(3))

</script>